option. This patch adds a restart sequence counter to xenstore.
The completion of a VM reboot is detected by observing that
its restart sequence counter changes.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
if security[idx][0] == 'ssidref':
to_store['security/ssidref'] = str(security[idx][1])
+ if not self.readVm('xend/restart_count'):
+ to_store['xend/restart_count'] = str(0)
+
log.debug("Storing VM details: %s", to_store)
self.writeVm(to_store)
def setResume(self, state):
self.info['resume'] = state
+ def getRestartCount(self):
+ return self.readVm('xend/restart_count')
+
def refreshShutdown(self, xeninfo = None):
# If set at the end of this method, a restart is required, with the
# given reason. This restart has to be done out of the scope of
try:
new_dom = XendDomain.instance().domain_create(config)
new_dom.unpause()
+ rst_cnt = self.readVm('xend/restart_count')
+ rst_cnt = int(rst_cnt) + 1
+ self.writeVm('xend/restart_count', str(rst_cnt))
new_dom.removeVm(RESTART_IN_PROGRESS)
except:
if new_dom:
methods = ['device_create', 'device_configure', 'destroyDevice',
'getDeviceSxprs',
'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown',
- 'send_sysrq', 'getVCPUInfo', 'waitForDevices']
+ 'send_sysrq', 'getVCPUInfo', 'waitForDevices',
+ 'getRestartCount']
exclude = ['domain_create', 'domain_restore']
fn=set_true, default=0,
use='Shutdown and reboot.')
+def wait_reboot(opts, doms, rcs):
+ while doms:
+ alive = server.xend.domains(0)
+ reboot = []
+ for d in doms:
+ if d in alive:
+ rc = server.xend.domain.getRestartCount(d)
+ if rc == rcs[d]: continue
+ reboot.append(d)
+ else:
+ opts.info("Domain %s destroyed for failed in rebooting" % d)
+ doms.remove(d)
+ for d in reboot:
+ opts.info("Domain %s rebooted" % d)
+ doms.remove(d)
+ time.sleep(1)
+ opts.info("All domains rebooted")
+
+def wait_shutdown(opts, doms):
+ while doms:
+ alive = server.xend.domains(0)
+ dead = []
+ for d in doms:
+ if d in alive: continue
+ dead.append(d)
+ for d in dead:
+ opts.info("Domain %s terminated" % d)
+ doms.remove(d)
+ time.sleep(1)
+ opts.info("All domains terminated")
+
def shutdown(opts, doms, mode, wait):
+ rcs = {}
for d in doms:
+ rcs[d] = server.xend.domain.getRestartCount(d)
server.xend.domain.shutdown(d, mode)
+
if wait:
- while doms:
- alive = server.xend.domains(0)
- dead = []
- for d in doms:
- if d in alive: continue
- dead.append(d)
- for d in dead:
- opts.info("Domain %s terminated" % d)
- doms.remove(d)
- time.sleep(1)
- opts.info("All domains terminated")
+ if mode == 'reboot':
+ wait_reboot(opts, doms, rcs)
+ else:
+ wait_shutdown(opts, doms)
def shutdown_mode(opts):
if opts.vals.halt and opts.vals.reboot: